package com.newbingo.action;

import com.newbingo.dto.MemberDto;
import com.newbingo.service.imple.IMemberService;
import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.http.*;
import org.apache.struts2.ServletActionContext;

public class MemberForwardAction extends ActionSupport {

	private IMemberService memberService = null;
	private String uname;
	private String upwd;

	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {
		HttpSession session = ServletActionContext.getRequest().getSession();
		HttpServletRequest request=ServletActionContext.getRequest();
		MemberDto member = memberService.findByLogin(uname, upwd);	    
		if (member != null) {
			session.setAttribute("member", member);
			return "success";
		} else {
			return "fail";
		}
		
	}

//	public void getLoginIP(HttpServletRequest request) {
//		String ip = request.getHeader("x-forwarded-for");
//		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
//			ip = request.getHeader("Proxy-Client-IP");
//		}
//		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
//			ip = request.getHeader("WL-Proxy-Client-IP");
//		}
//		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
//			ip = request.getRemoteAddr();
//		}
//		System.out.println("IP地址："+ip);
//	}

	public IMemberService getMemberService() {
		return memberService;
	}

	public void setMemberService(IMemberService memberService) {
		this.memberService = memberService;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

	public String getUpwd() {
		return upwd;
	}

	public void setUpwd(String upwd) {
		this.upwd = upwd;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

}
